package com.sjft.cloud.extension.generate.properties;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;


import static com.baomidou.mybatisplus.annotation.IdType.INPUT;

/**
 * DbProperties
 *
 * @author Jin
 */
@Getter
@Setter
@ToString
public class TableConfigProperties {

    //需要生产的表
    private List<String> tables;
    //表名前缀
    private Boolean removeTablePrefix = true;
    //其他自己猜
    private Boolean enableBaseResultMap = true;
    private Boolean enableBaseColumnList = true;
    private Boolean enableSwagger = false;
    private Boolean enableEntityLombokMode = false;
    private Boolean enableCache = false;
    private Boolean enableActiveRecord = false;
    //主键类型
    private com.baomidou.mybatisplus.annotation.IdType IdType = INPUT;

    public String[] getTablePrefix() {
        //此处可以截取多个前缀
        if (removeTablePrefix) {
            return tables.stream().map(tableName -> {
                String[] tableNameSplitArray = tableName.split("_");
                if (tableNameSplitArray.length > 1) {
                    return tableNameSplitArray[0];
                }
                return "";
            }).toArray(String[]::new);
        }
        return new String[0];
    }

}
